package org.loong.crypto.extension.crmf;

import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.crmf.CRMFObjectIdentifiers;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.cert.crmf.Control;

public class ProtocolEncrKeyControl implements Control {

    public static final ASN1ObjectIdentifier type = CRMFObjectIdentifiers.id_regCtrl.branch("6");

    private final SubjectPublicKeyInfo protocolEncrKey;

    /**
     * Basic constructor - build from a SubjectPublicKeyInfo representing the token.
     *
     * @param protocolEncrKey SubjectPublicKeyInfo.
     */
    public ProtocolEncrKeyControl(SubjectPublicKeyInfo protocolEncrKey) {
        this.protocolEncrKey = protocolEncrKey;
    }

    /**
     * Return the type of this control.
     *
     * @return id_regCtrl_protocolEncrKey
     */
    public ASN1ObjectIdentifier getType() {
        return type;
    }

    /**
     * Return the token associated with this control (a UTF8String).
     *
     * @return a UTF8String.
     */
    public ASN1Encodable getValue() {
        return protocolEncrKey;
    }
}
